package freighttmpl

import (
	"context"

	"mall/service/backend/api/internal/svc"
	"mall/service/backend/api/internal/types"
	"mall/service/setting/rpc/settingclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type RestoreFreightTemplateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewRestoreFreightTemplateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RestoreFreightTemplateLogic {
	return &RestoreFreightTemplateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *RestoreFreightTemplateLogic) RestoreFreightTemplate(req *types.IDsReq) (resp *types.BaseMsgResp, err error) {
	res, err := l.svcCtx.SettingRpc.BackendRestoreFreightTemplate(l.ctx, &settingclient.IDsReq{
		Ids: req.Ids,
	})
	if err != nil {
		return
	}

	return &types.BaseMsgResp{
		Success: true,
		Msg:     l.svcCtx.Trans.Trans(l.ctx, res.Msg),
	}, nil
}
